#include<bits/stdc++.h>
using namespace std;
struct car{
    int d,a,v;
    double s,d1;
};
int n,m,L,V,T,chaosu;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    scanf("%d %d %d %d",&n,&m,&L,&V);
    int vis[m];
    car c[T];
    for(int i=0;i<T;i++){
        scanf("%d %d %d",&c[i].d,&c[i].a,&c[i].v);
    }
    for(int i=0;i<m;i++){
        scanf("%d",&vis[i]);
    }
    for(int i=0;i<T;i++){
        if(c[i].a==0){
            if(c[i].v>V)chaosu++;
            else if(c[i].v<=V)continue;
        }else{
            if(c[i].v<=V&&c[i].a<0)continue;
            if(c[i].v>V&&c[i].a>0){
                chaosu++;
                continue;
            }
            c[i].s=(V*V-c[i].a*c[i].a)/(2*c[i].a);
            if(c[i].s<=0)continue;
            c[i].d1=c[i].d+c[i].s;
            int tmp_j=0;
            for(int j=0;j<m;j++){
                if(c[i].a>0){
                    if(vis[j]>c[i].d1){
                        vis[j]++;
                        tmp_j++;
                    }
                }else{
                    if(vis[j]>=c[i].d&&vis[j]<=c[i].d1){
                        vis[j]++;
                        tmp_j++;
                    }
                }
            }
            if(tmp_j>0)chaosu++;
        }
    }
    int clo_m=0;
    for(int i=0;i<m;i++){
        if(vis[i]==0)clo_m++;
    }
    printf("%d %d",chaosu,clo_m);
    fclose(stdin);
    fclose(stdout);
    return 0;
}
